import 'package:flutter_deer/generated/json/base/json_convert_content.dart';
import 'package:flutter_deer/database/beans/get_user_info_entity.dart';
import 'package:sp_util/sp_util.dart';

import 'package:flutter_deer/res/constant.dart';


GetUserInfoEntity $GetUserInfoEntityFromJson(Map<String, dynamic> json) {
  final GetUserInfoEntity getUserInfoEntity = GetUserInfoEntity();
  final bool? accountNonExpired = jsonConvert.convert<bool>(json['accountNonExpired']);
  if (accountNonExpired != null) {
    getUserInfoEntity.accountNonExpired = accountNonExpired;
  }
  final bool? accountNonLocked = jsonConvert.convert<bool>(json['accountNonLocked']);
  if (accountNonLocked != null) {
    getUserInfoEntity.accountNonLocked = accountNonLocked;
  }
  final int? admin = jsonConvert.convert<int>(json['admin']);
  if (admin != null) {
    getUserInfoEntity.admin = admin;
  }
  final List<GetUserInfoAuthorities>? authorities = (json['authorities'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<GetUserInfoAuthorities>(e) as GetUserInfoAuthorities).toList();
  if (authorities != null) {
    getUserInfoEntity.authorities = authorities;
  }
  final String? clientId = jsonConvert.convert<String>(json['clientId']);
  if (clientId != null) {
    getUserInfoEntity.clientId = clientId;
  }
  final String? clientType = jsonConvert.convert<String>(json['clientType']);
  if (clientType != null) {
    getUserInfoEntity.clientType = clientType;
  }
  final bool? credentialsNonExpired = jsonConvert.convert<bool>(json['credentialsNonExpired']);
  if (credentialsNonExpired != null) {
    getUserInfoEntity.credentialsNonExpired = credentialsNonExpired;
  }
  final bool? dataAllFlag = jsonConvert.convert<bool>(json['dataAllFlag']);
  if (dataAllFlag != null) {
    getUserInfoEntity.dataAllFlag = dataAllFlag;
  }
  final String? deviceId = jsonConvert.convert<String>(json['deviceId']);
  if (deviceId != null) {
    getUserInfoEntity.deviceId = deviceId;
  }
  final String? email = jsonConvert.convert<String>(json['email']);
  if (email != null) {
    getUserInfoEntity.email = email;
  }
  final bool? enabled = jsonConvert.convert<bool>(json['enabled']);
  if (enabled != null) {
    getUserInfoEntity.enabled = enabled;
  }
  final String? groupMerchantCode = jsonConvert.convert<String>(json['groupMerchantCode']);
  if (groupMerchantCode != null) {
    getUserInfoEntity.groupMerchantCode = groupMerchantCode;
  }
  final bool? hasOpPassword = jsonConvert.convert<bool>(json['hasOpPassword']);
  if (hasOpPassword != null) {
    getUserInfoEntity.hasOpPassword = hasOpPassword;
  }
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    getUserInfoEntity.id = id;
  }
  final String? loginMchId = jsonConvert.convert<String>(json['loginMchId']);
  if (loginMchId != null) {
    getUserInfoEntity.loginMchId = loginMchId;
  }
  final String? loginMerchantCode = jsonConvert.convert<String>(json['loginMerchantCode']);
  if (loginMerchantCode != null) {
    getUserInfoEntity.loginMerchantCode = loginMerchantCode;
  }
  final String? loginMerchantName = jsonConvert.convert<String>(json['loginMerchantName']);
  if (loginMerchantName != null) {
    getUserInfoEntity.loginMerchantName = loginMerchantName;
  }
  final int? loginMerchantType = jsonConvert.convert<int>(json['loginMerchantType']);
  if (loginMerchantType != null) {
    getUserInfoEntity.loginMerchantType = loginMerchantType;
  }
  final String? merchantUserId = jsonConvert.convert<String>(json['merchantUserId']);
  if (merchantUserId != null) {
    getUserInfoEntity.merchantUserId = merchantUserId;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    getUserInfoEntity.name = name;
  }
  final List<String>? needPasswordPermissions = (json['needPasswordPermissions'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<String>(e) as String).toList();
  if (needPasswordPermissions != null) {
    getUserInfoEntity.needPasswordPermissions = needPasswordPermissions;
  }
  final int? orderViewPermission = jsonConvert.convert<int>(json['orderViewPermission']);
  if (orderViewPermission != null) {
    getUserInfoEntity.orderViewPermission = orderViewPermission;
  }
  final String? originSystemCode = jsonConvert.convert<String>(json['originSystemCode']);
  if (originSystemCode != null) {
    getUserInfoEntity.originSystemCode = originSystemCode;
  }
  final List<String>? permissions = (json['permissions'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<String>(e) as String).toList();
  if (permissions != null) {
    getUserInfoEntity.permissions = permissions;
  }
  final String? productClientType = jsonConvert.convert<String>(json['productClientType']);
  if (productClientType != null) {
    getUserInfoEntity.productClientType = productClientType;
  }
  final String? productLine = jsonConvert.convert<String>(json['productLine']);
  if (productLine != null) {
    getUserInfoEntity.productLine = productLine;
  }
  final String? systemCode = jsonConvert.convert<String>(json['systemCode']);
  if (systemCode != null) {
    getUserInfoEntity.systemCode = systemCode;
  }
  final String? testField = jsonConvert.convert<String>(json['testField']);
  if (testField != null) {
    getUserInfoEntity.testField = testField;
  }
  final String? username = jsonConvert.convert<String>(json['username']);
  if (username != null) {
    getUserInfoEntity.username = username;
  }
  return getUserInfoEntity;
}

Map<String, dynamic> $GetUserInfoEntityToJson(GetUserInfoEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['accountNonExpired'] = entity.accountNonExpired;
  data['accountNonLocked'] = entity.accountNonLocked;
  data['admin'] = entity.admin;
  data['authorities'] = entity.authorities?.map((v) => v.toJson()).toList();
  data['clientId'] = entity.clientId;
  data['clientType'] = entity.clientType;
  data['credentialsNonExpired'] = entity.credentialsNonExpired;
  data['dataAllFlag'] = entity.dataAllFlag;
  data['deviceId'] = entity.deviceId;
  data['email'] = entity.email;
  data['enabled'] = entity.enabled;
  data['groupMerchantCode'] = entity.groupMerchantCode;
  data['hasOpPassword'] = entity.hasOpPassword;
  data['id'] = entity.id;
  data['loginMchId'] = entity.loginMchId;
  data['loginMerchantCode'] = entity.loginMerchantCode;
  data['loginMerchantName'] = entity.loginMerchantName;
  data['loginMerchantType'] = entity.loginMerchantType;
  data['merchantUserId'] = entity.merchantUserId;
  data['name'] = entity.name;
  data['needPasswordPermissions'] = entity.needPasswordPermissions;
  data['orderViewPermission'] = entity.orderViewPermission;
  data['originSystemCode'] = entity.originSystemCode;
  data['permissions'] = entity.permissions;
  data['productClientType'] = entity.productClientType;
  data['productLine'] = entity.productLine;
  data['systemCode'] = entity.systemCode;
  data['testField'] = entity.testField;
  data['username'] = entity.username;
  return data;
}

extension GetUserInfoEntityExtension on GetUserInfoEntity {
  GetUserInfoEntity copyWith({
    bool? accountNonExpired,
    bool? accountNonLocked,
    int? admin,
    List<GetUserInfoAuthorities>? authorities,
    String? clientId,
    String? clientType,
    bool? credentialsNonExpired,
    bool? dataAllFlag,
    String? deviceId,
    String? email,
    bool? enabled,
    String? groupMerchantCode,
    bool? hasOpPassword,
    String? id,
    String? loginMchId,
    String? loginMerchantCode,
    String? loginMerchantName,
    int? loginMerchantType,
    String? merchantUserId,
    String? name,
    List<String>? needPasswordPermissions,
    int? orderViewPermission,
    String? originSystemCode,
    List<String>? permissions,
    String? productClientType,
    String? productLine,
    String? systemCode,
    String? testField,
    String? username,
  }) {
    return GetUserInfoEntity()
      ..accountNonExpired = accountNonExpired ?? this.accountNonExpired
      ..accountNonLocked = accountNonLocked ?? this.accountNonLocked
      ..admin = admin ?? this.admin
      ..authorities = authorities ?? this.authorities
      ..clientId = clientId ?? this.clientId
      ..clientType = clientType ?? this.clientType
      ..credentialsNonExpired = credentialsNonExpired ?? this.credentialsNonExpired
      ..dataAllFlag = dataAllFlag ?? this.dataAllFlag
      ..deviceId = deviceId ?? this.deviceId
      ..email = email ?? this.email
      ..enabled = enabled ?? this.enabled
      ..groupMerchantCode = groupMerchantCode ?? this.groupMerchantCode
      ..hasOpPassword = hasOpPassword ?? this.hasOpPassword
      ..id = id ?? this.id
      ..loginMchId = loginMchId ?? this.loginMchId
      ..loginMerchantCode = loginMerchantCode ?? this.loginMerchantCode
      ..loginMerchantName = loginMerchantName ?? this.loginMerchantName
      ..loginMerchantType = loginMerchantType ?? this.loginMerchantType
      ..merchantUserId = merchantUserId ?? this.merchantUserId
      ..name = name ?? this.name
      ..needPasswordPermissions = needPasswordPermissions ?? this.needPasswordPermissions
      ..orderViewPermission = orderViewPermission ?? this.orderViewPermission
      ..originSystemCode = originSystemCode ?? this.originSystemCode
      ..permissions = permissions ?? this.permissions
      ..productClientType = productClientType ?? this.productClientType
      ..productLine = productLine ?? this.productLine
      ..systemCode = systemCode ?? this.systemCode
      ..testField = testField ?? this.testField
      ..username = username ?? this.username;
  }
}

GetUserInfoAuthorities $GetUserInfoAuthoritiesFromJson(Map<String, dynamic> json) {
  final GetUserInfoAuthorities getUserInfoAuthorities = GetUserInfoAuthorities();
  final String? component = jsonConvert.convert<String>(json['component']);
  if (component != null) {
    getUserInfoAuthorities.component = component;
  }
  final bool? hideInMenu = jsonConvert.convert<bool>(json['hideInMenu']);
  if (hideInMenu != null) {
    getUserInfoAuthorities.hideInMenu = hideInMenu;
  }
  final String? icon = jsonConvert.convert<String>(json['icon']);
  if (icon != null) {
    getUserInfoAuthorities.icon = icon;
  }
  final String? iconType = jsonConvert.convert<String>(json['iconType']);
  if (iconType != null) {
    getUserInfoAuthorities.iconType = iconType;
  }
  final String? label = jsonConvert.convert<String>(json['label']);
  if (label != null) {
    getUserInfoAuthorities.label = label;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    getUserInfoAuthorities.name = name;
  }
  final String? path = jsonConvert.convert<String>(json['path']);
  if (path != null) {
    getUserInfoAuthorities.path = path;
  }
  final String? redirect = jsonConvert.convert<String>(json['redirect']);
  if (redirect != null) {
    getUserInfoAuthorities.redirect = redirect;
  }
  final List<dynamic>? routes = (json['routes'] as List<dynamic>?)?.map(
          (e) => e).toList();
  if (routes != null) {
    getUserInfoAuthorities.routes = routes;
  }
  final String? target = jsonConvert.convert<String>(json['target']);
  if (target != null) {
    getUserInfoAuthorities.target = target;
  }
  return getUserInfoAuthorities;
}

Map<String, dynamic> $GetUserInfoAuthoritiesToJson(GetUserInfoAuthorities entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['component'] = entity.component;
  data['hideInMenu'] = entity.hideInMenu;
  data['icon'] = entity.icon;
  data['iconType'] = entity.iconType;
  data['label'] = entity.label;
  data['name'] = entity.name;
  data['path'] = entity.path;
  data['redirect'] = entity.redirect;
  data['routes'] = entity.routes;
  data['target'] = entity.target;
  return data;
}

extension GetUserInfoAuthoritiesExtension on GetUserInfoAuthorities {
  GetUserInfoAuthorities copyWith({
    String? component,
    bool? hideInMenu,
    String? icon,
    String? iconType,
    String? label,
    String? name,
    String? path,
    String? redirect,
    List<dynamic>? routes,
    String? target,
  }) {
    return GetUserInfoAuthorities()
      ..component = component ?? this.component
      ..hideInMenu = hideInMenu ?? this.hideInMenu
      ..icon = icon ?? this.icon
      ..iconType = iconType ?? this.iconType
      ..label = label ?? this.label
      ..name = name ?? this.name
      ..path = path ?? this.path
      ..redirect = redirect ?? this.redirect
      ..routes = routes ?? this.routes
      ..target = target ?? this.target;
  }
}